package net.itfenxiang.mybatisplus.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import net.itfenxiang.mybatisplus.entity.CardFaceValueCompany;
import net.itfenxiang.mybatisplus.dao.CardFaceValueCompanyMapper;
import net.itfenxiang.mybatisplus.query.CompanyQuery;
import net.itfenxiang.mybatisplus.service.ICardFaceValueCompanyService;
import net.itfenxiang.mybatisplus.utils.PageResult;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 企业开通卡种面值 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-04-29
 */
@Service
@AllArgsConstructor
public class CardFaceValueCompanyServiceImpl extends BaseServiceImpl<CardFaceValueCompanyMapper, CardFaceValueCompany> implements ICardFaceValueCompanyService {

    private final CardFaceValueCompanyMapper faceValueCompanyMapper;

    @Override
    public PageResult<CardFaceValueCompany> page(CompanyQuery query) {
        Map<String, Object> params = new HashMap<>();
        Page<CardFaceValueCompany> page = getPage(query);
        params.put("page", page);
        params.put("name", query.getName());
        params.put("type", query.getType());
        params.put("userId", query.getUserId());
        List<CardFaceValueCompany> cardFaceList = faceValueCompanyMapper.getFaceValueByUserIdOrCard(params);
        return new PageResult(cardFaceList, page.getTotal());
    }
}
